<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 形参前面加上3个点 可以接收所有实参
      const sum = (...args) => {
        let total = 0;
        args.forEach((item) => {
          total += item;
        });
        return total;
      };
      console.log(sum(10, 20));
      console.log(sum(10, 20, 30));
      let students = ["zs", "xz", "ls"];
      let [s1, ...s2] = students;
      console.log(s1);
      console.log(s2); // 接收的是一个数组 students 剩余元素
    </script>
  </body>
</html>
